﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InfoStuffStore.Common;

namespace InfoStuffStore
{
    public partial class FormDefault : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetRandomProducts();
                AddVisitor();
            }
        }

        private void GetRandomProducts()
        {
            using (DBDataContext dataContext = new DBDataContext())
            {
                GridProductList.DataSource = dataContext.GetRandomProducts();
                GridProductList.DataBind();
            }
        }

        private void AddVisitor()
        {
            using (DBDataContext dataContext = new DBDataContext())
            {
                dataContext.AddVisitor(Request.UserHostAddress);
            }
        }
    }
}